<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:p="http://primefaces.org/ui" template="/bootstraplayout.xhtml">


	<ui:define name="title">
		<h:outputText value="Edit Application" />

	</ui:define>



	<ui:define name="toptoolbar">

		<ui:include src="authenticatedtoolbar.xhtml" />

	</ui:define>

	<ui:define name="navigation">
		<p:menu>
			<p:submenu label="Actions">
				<p:menuitem value="View Applications" outcome="applications.jsf"
					icon="ui-icon-star" />

				<p:menuitem value="Add Application" outcome="newapplication.jsf"
					icon="ui-icon-star" />


			</p:submenu>

		</p:menu>
	</ui:define>

	<ui:define name="mainform">
		<p:panel header="Edit Application" id="editapplication">
			<p:messages id="messages" showSummary="true" />

			<h:panelGrid columns="2" id="dynaFormGroup" layout="block"
				style="margin-top: 15px;">


				<p:outputLabel value="Name:" for="name" />

				<p:inputText id="name" style="width:75%" size="100"
					value="#{editApplicationForm.application.name}" required="true" />


				<p:outputLabel value="Description:" for="description" />

				<p:inputTextarea rows="4" cols="20" id="description" style="width:75%"
					value="#{editApplicationForm.application.description}" />


			</h:panelGrid>

			<p:commandButton value="Save" style="margin-right:20px;"
				icon="ui-icon-disk" action="#{editApplicationForm.save}"
				update="editapplication" process="editapplication"
				styleClass="ui-btn-success" />
			<p:commandButton type="reset" value="#{msg.reset}"
				style="margin-left: 5px;" />

		</p:panel>

		<p:spacer height="2" />

		<p:dataTable id="twitters" var="t"
			value="#{editApplicationForm.twitterApps}">

			<f:facet name="header">
				<h:outputText value="Twitter Apps" />


				<p:commandButton value="New"
					styleClass="ui-priority-primary pull-right"
					actionListener="#{editApplicationForm.twitterInit}" process="@this"
					oncomplete="newTwitter.show()" update=":mainform:newTwitter" />

			</f:facet>


			<p:column headerText="Name">
				<h:outputText value="#{t.name}" />
			</p:column>

			<p:column headerText="Consumer Key">
				<h:outputText value="#{t.consumerKey}" />
			</p:column>

			<p:column headerText="Consumer Secret">
				<h:outputText value="#{t.consumerSecret}" />
			</p:column>

			<p:column headerText="Access Token">
				<h:outputText value="#{t.accessToken}" />
			</p:column>

			<p:column headerText="Access Token Secret">
				<h:outputText value="#{t.accessTokenSecret}" />
			</p:column>

			<p:column headerText="Public Key">
				<h:outputText value="#{t.publicKey}" />
			</p:column>

			<p:column headerText="Private Key">
				<h:outputText value="#{t.id}" />
			</p:column>


		</p:dataTable>



		<p:dialog header="New Twitter" widgetVar="newTwitter"
			resizable="false" id="newTwitter" showEffect="fade"
			hideEffect="explode" modal="true">
				
			<p:messages id="twittermsg" showSummary="true" />
				
			<h:panelGrid columns="2" cellpadding="4" id="newtwitterPanel"
				style="margin:0 auto;">


				<h:outputText value="Name:" />
				<p:inputText value="#{editApplicationForm.twitterApp.name}" required="true"/>

				<h:outputText value="Consumer Key:" />
				<p:inputText value="#{editApplicationForm.twitterApp.consumerKey}" required="true"/>

				<h:outputText value="Consumer Secret:" />
				<p:inputText value="#{editApplicationForm.twitterApp.consumerSecret}" required="true"/>

				<h:outputText value="Access Token:" />
				<p:inputText value="#{editApplicationForm.twitterApp.accessToken}" required="true"/>
				
				<h:outputText value="Access Token Secret:" />
				<p:inputText value="#{editApplicationForm.twitterApp.accessTokenSecret}" required="true"/>
				
				<h:outputText value="Private Key:" />
				<h:outputText value="#{editApplicationForm.twitterApp.id}" />
				
				<h:outputText value="Public Key:" />
				<h:outputText value="#{editApplicationForm.twitterApp.publicKey}" />
				
				
				<p:commandButton value="Save"
					actionListener="#{editApplicationForm.saveTwitter}" process="newtwitterPanel" 
					 update="newtwitterPanel twittermsg :mainform:twitters" />
					 
				<p:commandButton value="Close" onclick="newTwitter.hide()"/>	 

			</h:panelGrid>

		</p:dialog>




	</ui:define>



</ui:composition>